package com.example.idachuappone.person.item;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.TextView;
import com.example.idachuappone.BaseActivity;
import com.example.idachuappone.R;

public class WebViewActivity extends BaseActivity {
    private Button btn_back;
    private String title;
    private TextView tv_title;
    private String url;
    private WebView webView;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_web_view);
        this.title = getIntent().getStringExtra("title");
        this.url = getIntent().getStringExtra("url");
        initView();
    }

    private void initView() {
        this.tv_title = (TextView) findViewById(R.id.tv_title);
        this.tv_title.setText(this.title);
        this.webView = (WebView) findViewById(R.id.webView1);
        this.webView.getSettings().setJavaScriptEnabled(true);
        this.webView.setWebViewClient(new WebViewClient() {
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return false;
            }
        });
        this.btn_back = (Button) findViewById(R.id.btn_back);
        this.btn_back.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                if (WebViewActivity.this.webView.canGoBack()) {
                    WebViewActivity.this.webView.goBack();
                } else {
                    WebViewActivity.this.finish();
                }
            }
        });
        this.webView.loadUrl(this.url);
    }
}
